home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: SoundSprocket.h
- * Author(s): Dan Venolia (DV)
- *
- * Contents: Public interfaces for sound localization routines.
- *
- * Copyright (c) 1996 Apple Computer, Inc.
- */
-
- #ifndef __SOUNDSPROCKET__
- #define __SOUNDSPROCKET__
-
- #include <Types.h>
-
- #include <QD3D.h>
- #include <QD3DCamera.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /*******************************************************************************
- * • TODO: This stuff will be moved to Errors.h
- ******************************************************************************/
- enum {
- nilParmErr = -1234,
- parmRangeErr,
- invalObjectErr,
- nonNormalErr,
- outOfMemErr,
- corruptionErr,
- tooManyListenersErr,
- notOrthogonalErr,
- wrongVersionErr,
- internalErr,
- tooManySourcesErr,
- notInstalledErr,
- unsupporedHardwareErr,
- zeroScaleErr
- };
-
-
- /*******************************************************************************
- * • TODO: This stuff will be moved to Sound.h
- ******************************************************************************/
- #include <SoundComponents.h>
-
- enum {
- siPreMixerSoundComponent = 'prmx',
- siPostMixerSoundComponent = 'psmx',
- kSoundEffectsType = 'snfx',
- kReverbSubType = 'revb'
- };
-
-
- struct SoundComponentLink {
- ComponentDescription description;/*Describes the sound component*/
- SoundSource mixerID; /*Reserved by Apple*/
- SoundSource * linkID; /*Reserved by Apple*/
- };
-
- typedef struct SoundComponentLink SoundComponentLink;
- typedef SoundComponentLink *SoundComponentLinkPtr;
-
-
- /*******************************************************************************
- * SndSetInfo/SndGetInfo Messages
- ******************************************************************************/
-
- /* Our subtype within kSoundEffectsType for siPreMixerSoundComponent */
- enum {
- kSnd3DSubType = 'snd3'
- };
-
-
- /* Selectors for sndSetInfo and SndGetInfo */
- enum {
- si3DCPULoadLimit = '3dll', /* Parameter: UInt32, SndGetInfo only */
- si3DSetup = '3dst', /* Parameter: Snd3DSetup, Set/Get */
- si3DInfo = '3dif' /* Parameter: Snd3DInfo, Set/Get */
- };
-
-
- enum {
- kSpeakerKindStereo = 0,
- kSpeakerKindMono = 1,
- kSpeakerKindHeadphones = 2
- };
-
-
- typedef struct Snd3DSetup {
- UInt32 speakerKind; /* Speaker configuration */
- float speakerAngle; /* Angle formed by user and speakers */
-
- UInt32 reserved0; /* Reserved for future use -- set to 0 */
- UInt32 reserved1; /* Reserved for future use -- set to 0 */
- } Snd3DSetup;
-
-
- enum {
- kMediumAir = 0,
- kMediumWater = 1
- };
-
-
- enum {
- kSourceModeLocalized = 0, /* Localized by source position */
- kSourceModeAmbient = 1, /* Coming from all around */
- kSourceModeBinaural = 2 /* Already binaurally localized */
- //• kSourceModeUnfiltered???
- };
-
-
- typedef struct SourceLocation {
- float longitude; /* Angle of the meridian -- pos is up */
- float latitude; /* Angle on the meridian -- pos is left */
- float distance; /* Distance between source and listener */
- float projectionAngle;/* Cos(angle) between cone and listener */
- float sourceVelocity; /* Speed of source toward the listener */
- float listenerVelocity;/*Speed of listener toward the source */
- } SourceLocation;
-
-
- typedef struct VirtualSource {
- float attenuation; /* Attenuation factor */
- SourceLocation location; /* Location of virtual source */
- } VirtualSource;
-
-
- typedef struct Snd3DInfo {
- UInt32 cpuLoad; /* CPU load vs. quality -- 0 is best */
-
- UInt32 medium; /* Medium for sound propagation */
- float humidity; /* Humidity when medium is air */
- float roomSize; /* Reverb model -- distance bet. walls */
- float roomReflectivity;/*Reverb model -- bounce attenuation */
- float reverbAttenuation;/*Reverb model -- mix level */
-
- UInt32 sourceMode; /* Type of filtering to apply */
- float referenceDistance;/*Nominal distance for recording */
- float coneAngleCos; /* Cos(angle/2) of attenuation cone */
- float coneAttenuation;/* Attenuation outside the cone */
- SourceLocation currentLocation;/* Location of the sound */
-
- UInt32 reserved0; /* Reserved for future use -- set to 0 */
- UInt32 reserved1; /* Reserved for future use -- set to 0 */
- UInt32 reserved2; /* Reserved for future use -- set to 0 */
- UInt32 reserved3; /* Reserved for future use -- set to 0 */
-
- UInt32 virtualSourceCount;/*Number of reflections */
- VirtualSource virtualSource[4];/*The reflections */
- } Snd3DInfo;
-
- /*******************************************************************************
- * Routines for Maniulating Listeners
- ******************************************************************************/
- typedef struct ListenerData* ListenerReference;
-
- OSStatus NewListener(
- ListenerReference* outListenerReference);
-
- OSStatus DisposeListener(
- ListenerReference inListenerReference);
-
- OSStatus SetListenerTransform(
- ListenerReference inListenerReference,
- const TQ3Matrix4x4* inTransform);
-
- OSStatus GetListenerTransform(
- ListenerReference inListenerReference,
- TQ3Matrix4x4* outTransform);
-
- OSStatus SetListenerPosition(
- ListenerReference inListenerReference,
- const TQ3Point3D* inPosition);
-
- OSStatus GetListenerPosition(
- ListenerReference inListenerReference,
- TQ3Point3D* outPosition);
-
- OSStatus SetListenerOrientation(
- ListenerReference inListenerReference,
- const TQ3Vector3D* inOrientation);
-
- OSStatus GetListenerOrientation(
- ListenerReference inListenerReference,
- TQ3Vector3D* outOrientation);
-
- OSStatus SetListenerUpVector(
- ListenerReference inListenerReference,
- const TQ3Vector3D* inUpVector);
-
- OSStatus GetListenerUpVector(
- ListenerReference inListenerReference,
- TQ3Vector3D* outUpVector);
-
- OSStatus SetListenerCameraPlacement(
- ListenerReference inListenerReference,
- const TQ3CameraPlacement* inCameraPlacement);
-
- OSStatus GetListenerCameraPlacement(
- ListenerReference inListenerReference,
- TQ3CameraPlacement* outCameraPlacement);
-
- OSStatus SetListenerVelocity(
- ListenerReference inListenerReference,
- const TQ3Vector3D* inVelocity);
-
- OSStatus GetListenerVelocity(
- ListenerReference inListenerReference,
- TQ3Vector3D* outVelocity);
-
- OSStatus GetListenerActualVelocity(
- ListenerReference inListenerReference,
- TQ3Vector3D* outVelocity);
-
- OSStatus SetListenerCPULoad(
- ListenerReference inListenerReference,
- UInt32 inCPULoad);
-
- OSStatus GetListenerCPULoad(
- ListenerReference inListenerReference,
- UInt32* outCPULoad);
-
- OSStatus GetCPULoadLimit(
- UInt32* outCPULoadLimit);
-
- OSStatus SetListenerMedium(
- ListenerReference inListenerReference,
- UInt32 inMedium,
- float inHumidity);
-
- OSStatus GetListenerMedium(
- ListenerReference inListenerReference,
- UInt32* outMedium,
- float* outHumidity);
-
- OSStatus SetListenerReverb(
- ListenerReference inListenerReference,
- float inRoomSize,
- float inRoomReflectivity,
- float inReverbAttenuation);
-
- OSStatus GetListenerReverb(
- ListenerReference inListenerReference,
- float* outRoomSize,
- float* outRoomReflectivity,
- float* outReverbAttenuation);
-
- OSStatus SetListenerMetersPerUnit(
- ListenerReference inListenerReference,
- float inMetersPerUnit);
-
- OSStatus GetListenerMetersPerUnit(
- ListenerReference inListenerReference,
- float* outMetersPerUnit);
-
-
- /*******************************************************************************
- * Routines for Manipulating Sources
- ******************************************************************************/
- typedef struct SourceData* SourceReference;
-
- OSStatus NewSource(
- SourceReference* outSourceReference);
-
- OSStatus DisposeSource(
- SourceReference inSourceReference);
-
- OSStatus GetSource3DInfo(
- SourceReference inSourceReference,
- ListenerReference inListenerReference,
- Snd3DInfo* out3DInfo);
-
- OSStatus SetSourceTransform(
- SourceReference inSourceReference,
- const TQ3Matrix4x4* inTransform);
-
- OSStatus GetSourceTransform(
- SourceReference inSourceReference,
- TQ3Matrix4x4* outTransform);
-
- OSStatus SetSourcePosition(
- SourceReference inSourceReference,
- const TQ3Point3D* inPosition);
-
- OSStatus GetSourcePosition(
- SourceReference inSourceReference,
- TQ3Point3D* outPosition);
-
- OSStatus SetSourceOrientation(
- SourceReference inSourceReference,
- const TQ3Vector3D* inOrientation);
-
- OSStatus GetSourceOrientation(
- SourceReference inSourceReference,
- TQ3Vector3D* outOrientation);
-
- OSStatus SetSourceUpVector(
- SourceReference inSourceReference,
- const TQ3Vector3D* inUpVector);
-
- OSStatus GetSourceUpVector(
- SourceReference inSourceReference,
- TQ3Vector3D* outUpVector);
-
- OSStatus SetSourceCameraPlacement(
- SourceReference inSourceReference,
- const TQ3CameraPlacement* inCameraPlacement);
-
- OSStatus GetSourceCameraPlacement(
- SourceReference inSourceReference,
- TQ3CameraPlacement* outCameraPlacement);
-
- OSStatus SetSourceVelocity(
- SourceReference inSourceReference,
- const TQ3Vector3D* inVelocity);
-
- OSStatus GetSourceVelocity(
- SourceReference inSourceReference,
- TQ3Vector3D* outVelocity);
-
- OSStatus GetSourceActualVelocity(
- SourceReference inSourceReference,
- TQ3Vector3D* outVelocity);
-
- OSStatus SetSourceMode(
- SourceReference inSourceReference,
- UInt32 inMode);
-
- OSStatus GetSourceMode(
- SourceReference inSourceReference,
- UInt32* outMode);
-
- OSStatus SetSourceReferenceDistance(
- SourceReference inSourceReference,
- float inReferenceDistance);
-
- OSStatus GetSourceReferenceDistance(
- SourceReference inSourceReference,
- float* outReferenceDistance);
-
- OSStatus SetSourceSize(
- SourceReference inSourceReference,
- float inLength,
- float inWidth,
- float inHeight);
-
- OSStatus GetSourceSize(
- SourceReference inSourceReference,
- float* outLength,
- float* outWidth,
- float* outHeight);
-
- OSStatus SetSourceAngularAttenuation(
- SourceReference inSourceReference,
- float inConeAngle,
- float inConeAttenuation);
-
- OSStatus GetSourceAngularAttenuation(
- SourceReference inSourceReference,
- float* outConeAngle,
- float* outConeAttenuation);
-
-
- /*******************************************************************************
- * The following is here for use with versions of the Sound Manager before
- * version 3.2.1d2+ that did not support the siPreMixerSoundComponent message.
- * To use an older SoundManager, you should #define COMPILE_TIME_PATCH 1 in
- * your prefix file. This installs the "compile-time patch" on SndGetInfo
- * and SndSetInfo to catch the messages that the 3D spatial sound filter
- * component normally handles. All other messages are sent down to the real
- * calls.
- *
- * Since we are not using the real localization filter component, the effects
- * are limited to what we can do through the sound channel. Specifically this
- * means that we use volumeCmd and rateMultiplierCmd to implement the various
- * attenuation factors and Doppler effect. So no reverb effects, etc.
- *
- * WARNING: When COMPILE_TIME_PATCH is defined as 1, any volumeCmd and
- * rateMultiplierCmds that you send to your sound channel are
- * trounced when SndSetInfo is called with si3DInfo.
- ******************************************************************************/
- #ifndef COMPILE_TIME_PATCH
- #define COMPILE_TIME_PATCH 0
- #endif
-
- #if COMPILE_TIME_PATCH
- #include <Sound.h>
-
- #define SndSetInfo Patch_SndSetInfo
- #define SndGetInfo Patch_SndGetInfo
-
- OSErr Patch_SndSetInfo(
- SndChannelPtr inSndChannel,
- OSType inSelector,
- void* inData);
-
- OSErr Patch_SndGetInfo(
- SndChannelPtr inSndChannel,
- OSType inSelector,
- void* outData);
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __SOUNDSPROCKET__ */
-